//
//  WKDakaDetailImageTextCell.m
//  V-Learn
//
//  Created by Apple on 2019/3/20.
//  Copyright © 2019 yxk. All rights reserved.
//

#import "WKDakaDetailImageTextCell.h"

@implementation WKDakaDetailImageTextCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self setupUI];
    }
    return self;
}
+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *identifferCell = @"WKDakaDetailImageTextCell";
    WKDakaDetailImageTextCell *cell = [tableView dequeueReusableCellWithIdentifier:identifferCell];
    if (!cell) {
        cell = [[WKDakaDetailImageTextCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifferCell];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
    }
    return cell;
}
- (void)setupUI{
    
    self.icon = [[UIImageView alloc] init];
    self.icon.image = [UIImage imageNamed:@"wk_list_bgimg"];
    [self.contentView addSubview:self.icon];
    [self.icon makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(0);
        make.height.mas_equalTo(190);
    }];
    self.contentLab = [UILabel labelWithText:@"万思乐学小西妈双语工程万思乐学小西妈双语工程万思乐学小西妈双语工程万思乐学小西妈双语工程万思乐万思乐学小西妈双语工程万思乐学小西妈双语工程万思乐学小西妈双语工程万思乐学小西妈双语工程万思乐万思乐学小西妈双语工程万思乐学小西妈双语工程万思乐学小西妈双语工程万思乐学小西妈双语工程万思乐万思乐学小西妈双语工程万思乐学小西妈双语工程万思乐学小西妈双语工程万思乐学小西妈双语工程万思乐学小西妈双语工程" andTextColor:rgb(102,102,102) andName:nil andFontSize:14*kScaleFit];
    self.contentLab.numberOfLines = 0;
    [self.contentView addSubview:self.contentLab];
    [self.contentLab makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15*kScaleFit);
        make.top.mas_equalTo(self.icon.mas_bottom).mas_equalTo(10);
        make.right.mas_equalTo(-15*kScaleFit);
        make.bottom.mas_equalTo(-10);
    }];
    
}
- (void)setModel:(WKHotclockInfoVOListModel *)model{
    _model = model;
    self.contentLab.text = model.infoContent;
    if (model.infoFile) {
        self.icon.hidden = NO;
        NSString *urlString = [NSString stringWithFormat:@"%@%@",Public_URL,model.infoFile];
        [self.icon sd_setImageWithURL:[NSURL URLWithString:urlString] placeholderImage:[UIImage imageNamed:@"wk_list_bgimg"]];
    }else{
        self.icon.hidden = YES;
        [self.contentLab remakeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(15*kScaleFit);
            make.top.mas_equalTo(10);
            make.right.mas_equalTo(-15*kScaleFit);
            make.bottom.mas_equalTo(-10);
        }];
    }
    if (model.infoContent) {
        self.contentLab.hidden = NO;
    }else{
        self.contentLab.hidden = YES;
    }
    
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
